/**
 * https://hydro.ac/d/HUNNU/p/DataStructure0011
 * 三维不严格偏序，有重复点
 * 1. 排序时不能加等号，要用严格偏序
 * 2. 重复点在统计时不要计算，最后直接加入结果即可
 * 3. 归并的判断中加入第二维等号判断但又不能完全相等
 * 4. 树状数组统计时要统计到本身
 */
#include <bits/stdc++.h>
using namespace std;

#include <bits/extc++.h>
using namespace __gnu_pbds;

struct cdq_bit_t{ // CDQ套树状数组, 三维偏序

struct FenwickTree{ // 树状数组

using value_type = long long int;
using vec_type = vector<value_type>;

int n;
vec_type c;

FenwickTree() = default;

static int lowbit(int x){return x & -x;}

void init(int nn){this->c.assign((this->n=nn) + 1, 0);}

void modify(int pos, value_type delta){
    for(int i=pos;i<=this->n;i+=lowbit(i)) this->c[i] += delta;
}

value_type query(int pos)const{
    value_type ans = 0;
    for(int i=pos;i;i-=lowbit(i)) ans += this->c[i];
    return ans;
}

value_type query(int s, int e)const{return this->query(e) - this->query(s - 1);}

}Bt;

using value_t = int;
using cmp_t = function<bool(value_t, value_t)>;

struct _t{
    value_t x;
	value_t y;
	value_t z;
	int pos;
};

struct _t_hash {
    size_t operator () (const _t & t) const {
		return ((size_t)t.x * 13131 + t.y) * 13131 + t.z;
	}
	bool operator () (const _t & a, const _t & b) const {
		return a.x == b.x and a.y == b.y and a.z == b.z;
	}
};

int N;
vector<_t> A, B;
cmp_t cmp1, cmp2, cmp3;

void setCmp(cmp_t c1, cmp_t c2, cmp_t c3){
	cmp1 = c1; cmp2 = c2; cmp3 = c3;
}

void input(){
	cin >> N;
	A.assign(N, {});
	B.assign(N, {});
	int k = 0;
	for(auto & p : A) {
		cin >> p.x >> p.y >> p.z;
		p.pos = k++;
	} 
	return;
}

vector<int> Ans;
vector<value_t> W;

/// 计数器
__gnu_pbds::gp_hash_table<_t, int, _t_hash, _t_hash> Cnt;

void run(){
    Ans.assign(N, 0);
	sort(A.begin(), A.end(), [this](const _t & a, const _t & b){
		if(a.x != b.x) return this->cmp1(a.x, b.x);		
		if(a.y != b.y) return this->cmp2(a.y, b.y);
		if(a.z != b.z) return this->cmp3(a.z, b.z);
		return a.pos < b.pos;
	});
	
	/// 对z坐标离散化
	W.clear(); W.reserve(N + 2);
	W.push_back(INT_MIN);
	for(const auto & p : A) W.emplace_back(p.z);
	W.push_back(INT_MAX);
	sort(W.begin(), W.end(), this->cmp3);
	W.erase(unique(W.begin(), W.end()), W.end());

	int n = W.size();
	Bt.init(n);

	/// 计数器
	Cnt.clear();
	for(const auto & t : A){
		Cnt[t] += 1;
	}    

	CDQ(0, N - 1);

	/// 把自己重复的加上
	for(int i=0;i<N;++i){
		Ans[A[i].pos] += Cnt[A[i]] - 1;
	}    
	return;
}

void CDQ(int s, int e){
	if(s >= e) return;

	int mid = (s + e) >> 1;
	CDQ(s, mid); CDQ(mid + 1, e);

    static auto f = _t_hash();
    int u = s, v = mid + 1, t = s;
	while(u <= mid and v <= e){
        bool flag = this->cmp2(A[u].y, A[v].y);
        flag = flag or (A[u].y == A[v].y);
        flag = flag and (not f(A[u], A[v]));
        if(flag){
            auto p = lower_bound(W.begin(), W.end(), A[u].z, this->cmp3) - W.begin();
			Bt.modify(p, 1);
			B[t++] = A[u++];
		}else{ // 为否时说明[s, u)的y全都比v.y要小
			auto p = lower_bound(W.begin(), W.end(), A[v].z, this->cmp3) - W.begin();
            Ans[A[v].pos] += Bt.query(p); // Bt中是z也小的数量，要统计到z本身
			B[t++] = A[v++];
		}
	}
	while(u <= mid){
		auto p = lower_bound(W.begin(), W.end(), A[u].z, this->cmp3) - W.begin();
		Bt.modify(p, 1);      
		B[t++] = A[u++];  
	}
	while(v <= e){
		auto p = lower_bound(W.begin(), W.end(), A[v].z, this->cmp3) - W.begin();
		Ans[A[v].pos] += Bt.query(p); // Bt中是z也小的数量，要统计到z本身
		B[t++] = A[v++];
	}

	/// 清空树状数组
	for(int i=s;i<=mid;++i) {
		auto p = lower_bound(W.begin(), W.end(), A[i].z, this->cmp3) - W.begin();
		Bt.modify(p, -1);
	}

	copy(B.begin() + s, B.begin() + e + 1, A.begin() + s);
	return;
}

}CDQ;

int main() {
#ifndef ONLINE_JUDGE
    // freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    function<bool(int, int)> cmp[2] = {less<int>(), greater<int>()};
	CDQ.input();
	vector<array<int, 8>> ans(CDQ.N);
	for(int i=0;i<2;++i)for(int j=0;j<2;++j)for(int k=0;k<2;++k){
		CDQ.setCmp(cmp[i], cmp[j], cmp[k]);
		CDQ.run();
		for(int u=0;u<CDQ.N;++u){
			ans[u][(i<<2)|(j<<1)|k] = CDQ.Ans[u];
		}
	}
	for(const auto & a : ans){
		cout << a[0];
		for(int i=1;i<8;++i) cout << " " << a[i];
		cout << endl;
	}
    return 0;
}